<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>登录</title>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/bootstrap.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/font-awesome.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/theme.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/index.css}"/>
    <script th:src="@{/static/js/jquery.min.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/static/js/bootstrap.js}"></script>
    <script type="text/javascript" th:src="@{/static/layer/layer.js}"></script>
    <script th:src="@{/static/js/app.js}" type="text/javascript" charset="utf-8"></script>
</head>
<body style="background: #ECEDF0;">

<section class="body-sign">
    <div class="center-sign">
        <a href="#" class="logo pull-left">
            <h1>
                环球尚融管理后台
            </h1>
        </a>

        <div class="panel panel-sign">
            <div class="panel-title-sign mt-xl text-right">
                <h2 class="title text-uppercase text-bold m-none"><i class="fa fa-user mr-xs"></i> 登 录</h2>
            </div>
            <div class="panel-body">

                <div class="form-group mb-lg">
                    <label>用户名</label>
                    <div class="input-group input-group-icon">
                        <input id="username" name="username" type="text" class="form-control input-lg"/>
                        <span class="input-group-addon">
										<span class="icon icon-lg">
											<i class="fa fa-user"></i>
										</span>
									</span>
                    </div>
                </div>

                <div class="form-group mb-lg">
                    <div class="clearfix">
                        <label class="pull-left">密码</label>

                    </div>
                    <div class="input-group input-group-icon">
                        <input id="password" name="password" type="password" class="form-control input-lg"/>
                        <span class="input-group-addon">
										<span class="icon icon-lg">
											<i class="fa fa-lock"></i>
										</span>
									</span>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-3">
                        <div class="checkbox-custom checkbox-default">
                            <!--                                <input id="RememberMe" name="rememberme" type="checkbox"/>-->
                            <!--                                <label for="RememberMe">记住密码</label>-->
                        </div>
                    </div>
                    <div class="col-sm-4 text-right">
                        <button id="pc_login_btn" class="btn btn-primary hidden-xs" onclick="login()">登录
                        </button>
                        <button id="yd_login_btn" class="btn btn-primary btn-block btn-lg visible-xs mt-lg"
                                onclick="login()">登录
                        </button>
                    </div>
                </div>

                <br/>
                <!--                    <p class="text-center"><a href="">忘记密码？</a></p>-->
            </div>
        </div>

        <p class="text-center text-muted mt-md mb-md">&copy; Copyright 2020.</p>
    </div>
</section>
<script>
    function login() {
        var username = $("#username").val();
        var password = $("#password").val();
        if (username.length <= 0 || password.length <= 0) {
            layer.msg("账号或者密码不能为空", {icon: 5});
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '/admin/login',
            dataType: 'json',
            data: {
                username: username,
                password: password
            },
            success: function (res) {
                if (res.code == 200) {
                    layer.msg("登陆成功", {icon: 6});
                    window.location.replace("/admin/");
                } else if (res.code == 500) {
                    layer.msg(res.message, {icon: 5});
                }
            }
        });
    }
</script>
</body>
</html>